package com.yq.day18._03inner;


/**
 * @author 3307235355@qq.com
 * @since 2022/06/18 08:46
 * <p>
 * 成员内部类
 */
public class Demo01 {
    public static void main(String[] args) {
        A a = new A();
        a.test1();
        A.test3();
    }
}

class A {
    int a = 1;
    int b = 2;

    //外围类访问内部类的成员
    //成员方法
    public void test1() {
        //    直接new 一个对象
        B b = new B();
        System.out.println(b.a);
        System.out.println(b.b);
    }
    //静态成员方法
    public static void test3(){
        // 先创建外围类的对象
        A a1 = new A();
        B b = a1.new B();
        System.out.println(b.a);
        b.test();
    }

   private class B {
        int a = 10;

        // static int c=90;
        {
            a = 90;
        }

        int b = 45;
        static final int c = 90;

        // public  static void test(){}
        public void test() {
            System.out.println(a);
            System.out.println(b);
            System.out.println(A.this.a);
            System.out.println(A.this.b);
        }


    }

}
